package com.dxp.operation.exception;

public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 异常码
     */
    private ErrEnum errEnum;

    /**
     * 异常错误的具体信息
     */
    private Object data;

    public BusinessException(ErrEnum errEnum, Object data) {
        this(errEnum);
        this.data = data;
    }

    public BusinessException(ErrEnum errEnum) {
        super(errEnum.msg());
        this.errEnum = errEnum;
    }

    public BusinessException(Throwable cause) {
        super(ErrEnum.SERVER_ERR.msg(), cause);
        this.errEnum = ErrEnum.SERVER_ERR;
        this.data = cause;
    }

    public ErrEnum getErrEnum() {
        return errEnum;
    }

    public Object getData() {
        return data;
    }
}